# Maintainer: David Runge <dvzrv@archlinux.org>

_name=python3-saml
pkgname=python-saml
pkgver=1.16.0
pkgrel=1
pkgdesc="Python SAML Toolkit"
arch=(any)
url="https://github.com/SAML-Toolkits/python3-saml"
license=(MIT)
depends=(
  python
  python-isodate
  python-lxml
  python-xmlsec
)
makedepends=(
  python-build
  python-installer
  python-poetry-core
  python-setuptools
  python-wheel
)
checkdepends=(
  python-freezegun
  python-pytest
)
provides=(python-python3-saml)
source=($_name-$pkgver.tar.gz::$url/archive/refs/tags/v$pkgver.tar.gz)
sha512sums=('77e779a3d3190f3164105bbc2943b54729dfef12c71b0303a523acada95da291bc77b331a83726f00c503ef09040a05180c234620e5a65d4ea4fd88da24eeade')
b2sums=('94fc65caf978aeb30577ff435ce874c1fbb15dac0c5028e15a8adb21631496b9382d538c80ae77e1ba4166d2fbf22c7ac96bce7b6e3533589a6b8654f5be35ee')
validpgpkeys=()

prepare() {
  cd $_name-$pkgver
  sed -e 's/poetry>=1.1.15/poetry-core>=1.0.0/' -i pyproject.toml
}

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local pytest_options=(
    -vv
  )

  cd $_name-$pkgver
  export PYTHONPATH="$PWD/src:$PYTHONPATH"
  pytest "${pytest_options[@]}"
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
  install -vDm 644 README.md -t "$pkgdir/usr/share/doc/$pkgname/"
}
